﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UpdateServer
{
    public partial class DeleteHistory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userid = Session["USERID"] as string;
            if (string.IsNullOrEmpty(userid))
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                try {

                    string appID = Request.QueryString["APPID"];
                    string path = Server.MapPath("UploadFiles/" + appID);
                    if (System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.Delete(path, true);

                    }
                    System.IO.Directory.CreateDirectory(path);
                    ServerDataTableAdapters.T_APPS_VERSIONTableAdapter ad = new ServerDataTableAdapters.T_APPS_VERSIONTableAdapter();
                    ServerData.T_APPS_VERSIONDataTable dt = new ServerData.T_APPS_VERSIONDataTable();
                    ad.FillBy(dt, appID);
                    foreach (ServerData.T_APPS_VERSIONRow dr in dt.Rows)
                    {
                        dr.Delete();

                    }

                    ad.Update(dt);
                }
                catch { 
                
                }
                Response.Redirect("Default.aspx");
            }
        }
    }
}